home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / include / rast.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-23  |  3.3 KB  |  116 lines

  1. /* rast.h - header file for Sun raster files
  2. %
  3. % The format of a Sun raster file is as follows.  First, a struct
  4. % rasterfile.  Note the 32-bit magic number at the beginning; this
  5. % identifies the file type and lets you figure out whether you need
  6. % to do little-endian / big-endian byte-swapping or not.
  7. %
  8. % After the struct is an optional colormap.  If ras_maptype is RMT_NONE,
  9. % no map is present; if it's RMT_EQUAL_RGB then the map consists of
  10. % three unsigned-char arrays ras_maplength long, one each for r g and b.
  11. % I don't know what RMT_RAW means.  Black and white bitmaps are stored
  12. % as ras_maptype == RMT_NONE and ras_depth == 1, with the bits stored
  13. % eight to a byte MSB first.
  14. %
  15. % Finally comes the image data.  If ras_type is RT_OLD or RT_STANDARD,
  16. % the data is just plain old uncompressed bytes, padded out to a multiple
  17. % of 16 bits in each row.  If ras_type is RT_BYTE_ENCODED, a run-length
  18. % compression scheme is used: an escape-byte of 128 indicates a run;
  19. % the next byte is a count, and the one after that is the byte to be
  20. % replicated.  The one exception to this is if the count is 1; then
  21. % there is no third byte in the packet, it means to put a single 128
  22. % in the data stream.
  23. */
  24.  
  25. #ifndef _RAST_H_
  26. #define _RAST_H_
  27.  
  28. #ifdef __STDC__
  29. #define ARGS(alist) alist
  30. #else
  31. #define ARGS(alist) ()
  32. #endif    __STDC__
  33.  
  34. #define PIX_ERR        -1
  35.  
  36. struct rasterfile {
  37. #    define    RAS_MAGIC    0x59a66a95
  38.     long    ras_magic,
  39.         ras_width, ras_height,
  40.         ras_depth, ras_length,
  41.         ras_type, ras_maptype,
  42. #define RT_OLD        0    /* Raw pixrect image in 68000 byte order */
  43. #define RT_STANDARD    1    /* Raw pixrect image in 68000 byte order */
  44. #define RT_BYTE_ENCODED    2    /* Run-length compression of bytes */
  45. #define RT_FORMAT_RGB    3    /* XRGB or RGB instead of XBGR or BGR */
  46. #define RT_FORMAT_TIFF    4    /* tiff <-> standard rasterfile */
  47. #define RT_FORMAT_IFF    5    /* iff (TAAC format) <-> standard rasterfile */
  48. #define RT_EXPERIMENTAL 0xffff    /* Reserved for testing */
  49.  
  50. #define RMT_NONE    0
  51. #define RMT_EQUAL_RGB    1
  52. #define RMT_RAW        2
  53.         ras_maplength;
  54.     };
  55.  
  56. struct pixrectops {
  57.     int    (*pro_rop)(),
  58.         (*pro_stencil)(),
  59.         (*pro_batchrop)(),
  60.         (*pro_nop)(),
  61.         (*pro_destroy)(),
  62.         (*pro_get)(),
  63.         (*pro_put)(),
  64.         (*pro_vector)();
  65.     struct pixrect*    (*pro_region)();
  66.     int    (*pro_putcolormap)(),
  67.         (*pro_getcolormap)(),
  68.         (*pro_putattributes)(),
  69.         (*pro_getattributes)();
  70.     };
  71.  
  72. struct pr_size {
  73.     int    x, y;
  74.     };
  75. struct pr_pos {
  76.     int    x, y;
  77.     };
  78.  
  79. struct pixrect {
  80.     struct pixrectops*    pr_ops;
  81.     struct pr_size    pr_size;
  82.     int    pr_depth;
  83.     struct mpr_data    *pr_data; /* work-alike only handles memory pixrects */
  84.     };
  85.  
  86. struct mpr_data {
  87.     int    md_linebytes;
  88.     unsigned char*    md_image; /* note, byte not short -- avoid pr_flip() */
  89.     struct    pr_pos md_offset;
  90.     short    md_primary;
  91.     short    md_flags;
  92.     };
  93.  
  94. typedef struct {
  95.     int    type,
  96.         length;
  97.     unsigned char*    map[3];
  98.     } colormap_t;
  99.  
  100. /* And the routine definitions */
  101.  
  102. struct pixrect* mem_create    ARGS((int w, int h, int depth));
  103. void mem_free    ARGS((struct pixrect* p));
  104.  
  105. int pr_dump ARGS((struct pixrect* p, FILE* out, colormap_t* colormap, int type, int copy_flag));
  106.  
  107. int pr_load_header ARGS((FILE* in, struct rasterfile* hP));
  108.  
  109. int pr_load_colormap ARGS((FILE* in, struct rasterfile* hP, colormap_t* colormap));
  110.  
  111. struct pixrect* pr_load_image ARGS((FILE* in, struct rasterfile* hP, colormap_t* colormap));
  112.  
  113. extern    int    RED_to_GRAY, GREEN_to_GRAY, BLUE_to_GRAY;
  114.  
  115. #endif    _RAST_H_
  116.